package com.heima.feigns;

import com.heima.config.HeimaFeignAutoConfiguration;
import com.heima.feigns.fallback.WemediaFeignFallback;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

//声明feign客户端接口
@FeignClient(value = "leadnews-wemedia",    //要调用的微服务名称
        configuration = HeimaFeignAutoConfiguration.class,  //feign接口配置
        fallbackFactory = WemediaFeignFallback.class    //feign接口的服务降级类
)
public interface WemediaFeign {
    /**
     * 根据名称查询自媒体用户
     * @param name
     * @return
     */
    @GetMapping("/api/v1/user/findByName/{name}")
    ResponseResult<WmUser> findByName(@PathVariable("name") String name);

    /**
     * 保存自媒体用户
     * @param wmUser
     * @return
     */
    @PostMapping("/api/v1/user/save")
    ResponseResult<WmUser> save(@RequestBody WmUser wmUser);

    @GetMapping("/api/v1/news/one/{id}")
    public ResponseResult<WmNews> findWmNewsById(@PathVariable("id") Integer id);
    @PutMapping("/api/v1/news/update")
    ResponseResult updateWmNews(@RequestBody WmNews wmNews);
}
